<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>05用户注册</title>
</head>

<body>
  <p><label>用户名：<input type="text" placeholder="请输入用户名" id="username"></label></p>
  <p><label>密码：<input type="text" placeholder="请输入密码" id="password"></label></p>
  <p><label>手机号：<input type="text" placeholder="请输入手机号" id="telephone"></label></p>
  <p><button id="register">注册</button></p>
</body>
<script src="ajax.js"></script>
<script>
  var oUserName = document.querySelector('#username');
  var oPassword = document.querySelector('#password');
  var oTelephone = document.querySelector('#telephone');
  var oRegister = document.querySelector('#register');

  oRegister.onclick = function () {
    var username = oUserName.value;
    var password = oPassword.value;
    var telephone = oTelephone.value;
    // 前端验证

    ajax({
      // type: 'GET',
      path: 'http://localhost/1907/22user_register.php',
      data: {
        username,
        password,
        telephone
      },
      // dataType: 'json',
      successCB: ({ code, msg }) => {
        if (code) {
          // location.href = './07用户登录.html';
          alert(msg)
        } else {
          alert(msg);
        }
      }
    })

  }


</script>

</html>